﻿Imports System.Data
Imports System.Collections.ObjectModel 

Public Class CSCatalogo



Public Function ObtenerFondosIndeval(ByRef sMsgError As String ) As ObservableCollection (Of CTFondoIndeval )

  Dim lstFondosIndeval = New ObservableCollection  (Of CTFondoIndeval )

  Dim dt As DataTable

 dt = CFLServicioLocalSQLServerDB.ObtenerFondosIndeval ()

  If  dt is Nothing then 
       sMsgError = "No se pudo obtener el catálogo de Fondos-Indeval."
       Return lstFondosIndeval 
  End If


  For Each fondoDB As DataRow In dt.Rows
      Dim fondoIndeval  = New CTFondoIndeval 

      fondoIndeval.Fondo   = fondoDB("FONDO")
      fondoIndeval.Indeval = fondoDB ("CTO_INDEVAL")
    
      lstFondosIndeval.Add(fondoIndeval)
  Next


   Return lstFondosIndeval

End Function

Public Function ObtenerTVNGxIndeval(ByVal fondo As String, ByRef sMsgError As String ) As List(Of CTFondoTVNG)

  Dim lstFondosTVNG = New List(Of CTFondoTVNG)

  Dim dt As DataTable

 dt = CFLServicioLocalSQLServerDB.ObtenerTVNGxFondo(fondo)

  If  dt is Nothing then 
       sMsgError = "No se pudo obtener los negocios relacionados con el fondo."
       Return lstFondosTVNG 
  End If


  For Each fondoDB As DataRow In dt.Rows
      Dim fondoTVNG  = New CTFondoTVNG 

      fondoTVNG.IdTVNG  = fondoDB("ID_TVNG")
      fondoTVNG.TVNG     = fondoDB("TVNG")
      fondoTVNG.EsSeleccionado  = fondoDB ("SELECCIONADO")
    
      lstFondosTVNG.Add(fondoTVNG)
  Next


   Return lstFondosTVNG

End Function

Public Function ObtenerIntermediarioxFondo(ByVal fondo As String, ByRef sMsgError As String ) As List(Of CTFondoIntermediario)

  Dim lstFondosInter = New List(Of CTFondoIntermediario )

  Dim dt As DataTable

 dt = CFLServicioLocalSQLServerDB.ObtenerIntermediarioxFondo(fondo)

  If  dt is Nothing then 
       sMsgError = "No se pudo obtener los Intermediarios relacionados con el fondo."
       Return lstFondosInter 
  End If


  For Each fondoDB As DataRow In dt.Rows
      Dim fondoInter  = New CTFondoIntermediario  ()

      fondoInter.IdIntermediario  = fondoDB("ID_INTERMEDIARIO")
      fondoInter.Intermediario    = fondoDB("INTERMEDIARIO")
      fondoInter.Contrato         = fondoDB("CTO_INTERMEDIARIO")
      fondoInter.EsSeleccionado   = fondoDB ("SELECCIONADO")
    
      lstFondosInter.Add(fondoInter)
  Next


   Return lstFondosInter

End Function


Public Function ActualizarInterFondos(ByRef lstInterFondo As List(Of CTFondoIntermediario ), ByVal fondo As String, ByRef sMsgError As String) As Boolean
   Return   CFLServicioLocalSQLServerDB.ActualizarRelIntermediarioFondo (lstInterFondo,fondo,sMsgError) 
End Function

Public Function ActualizarTVNGFondos(ByRef lstTVNGFondo As List(Of CTFondoTVNG), ByVal fondo As String, ByRef sMsgError As String) As Boolean
   Return   CFLServicioLocalSQLServerDB.ActualizarRelTVNGFondo(lstTVNGFondo,fondo,sMsgError) 
End Function


Public  Function ActualizarFondo(ByRef Fondo As string, regCambio As CTFondoIndeval, ByRef sMsgError As String) As Boolean
    Return CFLServicioLocalSQLServerDB.ActualizarFondoIndeval (fondo,regCambio,sMsgError)    
End Function

Public Function DarDeAltaFondoIndeval(ByRef regNvo As CTFondoIndeval, ByRef sMsgError As String) As Boolean
    Return CFLServicioLocalSQLServerDB.DarDeAltaFondoIndeval(regNvo,sMsgError) 
End Function

Public Function EliminarFondoIndeval(ByRef regActual As CTFondoIndeval, ByRef sMsgError As String) As Boolean
     Return CFLServicioLocalSQLServerDB.EliminarFondoIndeval (regActual,sMsgError) 
End Function




End Class
